# -*- coding: utf-8 -*-

import sys
import os
from ConfigParser import *

class KiduxConfig:

    def __init__(self):
        self.conf = ConfigParser()
        homeDir = os.path.expanduser('~')
        userConfig = homeDir+"/.config/kidux/emesene/plugin.conf"

        if os.path.exists(userConfig):
            self.conf.read(userConfig)
        else:
            self.conf.read('/opt/kidux/etc/emesene/plugin.conf')

        self.fixSystemPath()


    def fixSystemPath(self):
        pluginDir = self.pluginDir()
        sys.path.append(pluginDir)
        sys.path.append(pluginDir+"/kidux")
        sys.path.append(pluginDir+"/impl")
        libUnicornPath = self.libUnicornPath()
        sys.path.append(libUnicornPath)

    def pluginDir(self):
        return self.conf.get("DEFAULT","plugin.dir")

    def libUnicornPath(self):
        return self.conf.get("DEFAULT","libunicorn")		

    def image(self, name):
        return self.conf.get('IMAGES','root')+"/"+name

